package com.bwie.bwedu.activity;

import android.content.Intent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;

import com.bwie.bwedu.R;
import com.bwie.bwedu.adapter.TrackInfoadapter;
import com.bwie.bwedu.bean.Student;
import com.bwie.bwedu.presenter.impl.TrackInfoPresenterImpl;
import com.bwie.bwedu.presenter.impl.TrackPresenterImpl;
import com.bwie.bwedu.utils.ASimpleCacheUtils;
import com.bwie.bwedu.utils.LogUtils;
import com.bwie.bwedu.view.TrackView;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/7/21.
 * 跟踪页面具体信息展示
 */
public class TrackInfoActivity extends BaseActivity implements TrackView {

    private ListView listview;
    private TextView title;
    private ImageButton back;
    private TrackInfoadapter adapter;
    private String id;

    @Override
    public int getLayout() {
        return R.layout.fragment_info_track;
    }

    @Override
    public void findView() {
        listview = (ListView) findViewById(R.id.track_info_list);
        back = (ImageButton) findViewById(R.id.item_title_back);
        title = (TextView) findViewById(R.id.item_title_title);
    }

    @Override
    public void setData() {
        Intent intent=getIntent();
        id = intent.getStringExtra("id");
        title.setText("历史信息");
        TrackInfoPresenterImpl presenter=new TrackInfoPresenterImpl(this);
        presenter.trackinfo(id);


    }

    @Override
    public void setListener() {
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void onSuccess(ArrayList<Student> list) {
        //成功
        adapter = new TrackInfoadapter(this,list);
        if(adapter!=null){
            listview.setAdapter(adapter);
            showToast("共有"+list.size()+"条信息");
        }
    }
    @Override
    public void onFail(String info) {
        //失败
        showToast(info);

    }
}
